home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
751-760
/
760
/
p-compress
/
objectfm
/
decrunchfm.s
< prev
Wrap
Text File
|
1995-03-18
|
3KB
|
145 lines
OPT ALINK
XREF _decompressFM
XDEF _DOSBase
movea.l a0,a4 preserve command line
clr.b -1(a4,d0.w)
lea dosname,a1
move.l 4,A6
jsr -408(a6) OldOpenLibrary
move.l d0,_DOSBase
move.l _DOSBase,A6
jsr -60(a6) Output
move.l d0,stdout
move.l a4,d1 input filename
move.l #1005,d2 MODE_OLDFILE
move.l _DOSBase,A6
jsr -30(a6) Open
move.l d0,fi input file handle
move.l #fname,d1 'ram:q'
move.l #1006,d2 MODE_NEWFILE
move.l _DOSBase,A6
jsr -30(a6) Open
move.l d0,fo output file-handle
move.l #6,d3 read 'lh,decompressed size'
move.l #buffer,d2
move.l fi,d1
move.l _DOSBase,A6
jsr -42(a6) Read
moveq.l #-1,d3
moveq.l #2,d2
move.l fi,d1
move.l _DOSBase,a6
jsr -66(a6) Seek to position in file after 'LH'
lea buffer,a0
cmpi.w #$4C48,(a0) check that file is compressed
beq compressed
move.l #$14,d3
move.l #notcomp,d2
move.l stdout,d1
move.l _DOSBase,a6
jsr -48(a6)
bra close
compressed
move.l length,d0
move.l #$10001,d1 MEMF_PUBLIC|MEMF_CLEAR
move.l 4,A6
jsr -198(a6) AllocMem
move.l d0,obuf
; move.l length,-(a7)
move.l obuf,-(a7)
move.l fi,-(a7)
jsr _decompressFM
addq.l #8,a7 add.l #$C,a7
cmpi #1,d0
bne decompOK
move.l #$14,d3
move.l #baddecomp,d2
move.l stdout,d1
move.l _DOSBase,a6
jsr -48(a6) Write
jmp close
decompOK
cmpi #2,d0
bne memOK
move.l #$21,d3
move.l #nomem,d2
move.l stdout,d1
move.l _DOSBase,a6
jsr -48(a6) Write
jmp close
memOK
move.l length,d3
move.l obuf,d2 Decoded output
move.l fo,d1
move.l _DOSBase,a6
jsr -48(a6) Write
;(insert code to use output in obuf)
close
tst.l fi
beq.b closefo
move.l fi,d1
move.l _DOSBase,A6
jsr -36(a6) Close
closefo
tst.l fo
beq.b freeobuf
move.l fo,d1
move.l _DOSBase,A6
jsr -36(a6) Close
freeobuf
tst.l obuf
beq.b quit
move.l obuf,a1
move.l length,d0
move.l 4,A6
jsr -210(a6) FreeMem
quit
rts
_DOSBase dc.l 0
fi dc.l 0
fo dc.l 0
stdout dc.l 0
obuf dc.l 0
buffer dc.w 0
length dc.l 0
dosname dc.b 'dos.library',0
fname dc.b 'ram:q',0
notcomp dc.b 'file not compressed',10,0
nomem dc.b 'insufficient memory',10,0
baddecomp dc.b 'decompression failed',10,0